var gulp = require('gulp');
//var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
// var uglify = require('gulp-uglify');
// var rename = require('gulp-rename');
var ts = require('gulp-typescript');


var descPath = './content/js/';

gulp.task('ts', function () {

    var tsResult = gulp.src('./TypeScripts/*.ts')
        .pipe(ts({
            sourceMap: true,
            noImplicitAny: true,
            declaration: true
        }));
    tsResult.js.pipe(gulp.dest('./TypeScripts/TsOut'));
    tsResult.dts
        .pipe(concat('Sail.JavaScript.d.ts'))
        .pipe(gulp.dest('./TypeScripts/tsd/'));
    //tsResult.dts.pipe(concat('Sail.JavaScript.d.ts')).pipe(gulp.dest('Sail.JavaScript/tsd'));
    gulp.run("scripts")
    return tsResult;
});


gulp.task('scripts', function () {
    gulp.src('./TypeScripts/TsOut/*.js')
        .pipe(concat('jPlugin.js'))
        .pipe(gulp.dest(descPath));        
});


gulp.task('default', function () {
    gulp.watch('./TypeScripts/*.ts', function () {
        gulp.run('ts');
    });    
});